package com.feihe.repository;

import com.feihe.entity.Calendar;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

@Repository
public interface CalendarRepository extends JpaRepository<Calendar, Long> {
    
    @Query("SELECT c FROM Calendar c WHERE c.startTime >= :startTime AND c.endTime <= :endTime")
    Optional<Calendar> findByTimeRange(@Param("startTime") LocalDateTime startTime, 
                                      @Param("endTime") LocalDateTime endTime);
    
    /**
     * 查询指定时间范围内的日历记录
     */
    List<Calendar> findByStartTimeBetween(LocalDateTime startTime, LocalDateTime endTime);
} 